﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Core.Modal;
using Core.Core;

namespace www.pages.word
{
    public partial class word : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack) {
                try {
                    hid_Project.Value = Request["project"].ToString();
                    hid_document.Value = Request["doc"].ToString();

                    BindDocument();

                    BindTags();
                }
                catch (Exception ex) {

                }                
            }
        }
        /// <summary>
        /// 
        /// </summary>
        private void BindTags()
        {
            this.listTags.DataSource=TagUtil.GetList(Convert.ToInt32(hid_Project.Value), Convert.ToInt32(hid_document.Value));
            this.listTags.DataBind();
        }
        /// <summary>
        /// 
        /// </summary>
        private void BindDocument()
        {
            modal_Document document = DocumentUtil.Get(Convert.ToInt32(hid_Project.Value), Convert.ToInt32(hid_document.Value));
            if (document != null)
            {
                this.txt_doc_name.Value = document.doc_name;
                this.txt_doc_comment.Value = document.doc_comment;
                this.editor1.Value = document.doc_template;
            }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="name"></param>
        /// <param name="comment"></param>
        /// <param name="content"></param>
        /// <param name="color"></param>
        /// <param name="typs"></param>
        /// <returns></returns>
        public string showTags(string id,string name, string comment, string content, string color, string typs) {
            return $"<div class=\"external-event tag\" style=\"background-color:{color}\" data-color=\"{color}\" data-tagid=\"{id}\" data-remark=\"{comment}\" data-content=\"{content}\">{name}</div>";
        }
    }
}